VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form lista 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   6600
   ClientLeft      =   48
   ClientTop       =   372
   ClientWidth     =   6852
   BeginProperty Font 
      Name            =   "Verdana"
      Size            =   9
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6600
   ScaleWidth      =   6852
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmd_borrar 
      Caption         =   "BORRAR"
      Height          =   375
      Left            =   2880
      TabIndex        =   3
      Top             =   120
      Visible         =   0   'False
      Width           =   1455
   End
   Begin VB.CommandButton cmd_edit 
      Caption         =   "EDITAR"
      Height          =   375
      Left            =   1440
      TabIndex        =   2
      Top             =   120
      Width           =   1455
   End
   Begin VB.CommandButton cmd_add 
      Caption         =   "ADICIONAR"
      Height          =   375
      Left            =   0
      TabIndex        =   1
      Top             =   120
      Width           =   1455
   End
   Begin MSFlexGridLib.MSFlexGrid listas 
      Height          =   6135
      Left            =   0
      TabIndex        =   0
      Top             =   480
      Width           =   6855
      _ExtentX        =   12086
      _ExtentY        =   10816
      _Version        =   393216
      Rows            =   5410
      Cols            =   5
      FixedCols       =   0
      ForeColor       =   4210752
      BackColorFixed  =   12640511
      ForeColorFixed  =   4210752
      BackColorSel    =   16777215
      BackColorBkg    =   16777215
      GridColorFixed  =   16777215
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
End
Attribute VB_Name = "lista"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const IMAGE_HEIGHT As Long = 44 '64
Private Sub Form_Activate()
'Activar
nombreform = Me.Name
End Sub
Private Sub Form_Unload(Cancel As Integer)
' detiene el msflexgrid
   DetenerScroll listas
End Sub
Private Sub Form_Load()
Dim aux As String
Dim i As Long, cont As Long
Dim j As Long, k As Long
Dim reg As ADODB.Recordset
Set reg = New ADODB.Recordset
Dim sql As String 'Consulta

 'MOSTRAR PASSWORD
' If cadParametros <> "" Then band = 1: Call cmd_edit_Click
 
Call conexion

'si la lista es usuario =1
Select Case band
Case Is = 1 'USUARIO
lista.cation = "USUARIO"

cont = CInt(devolverCont("count(login)", " administrador", 0))
listas.Rows = cont + 1
listas.Cols = 6 '5
With listas
.TextMatrix(0, 0) = "Nro."
.TextMatrix(0, 1) = UCase("usuario")
.TextMatrix(0, 2) = UCase("nombre")
.TextMatrix(0, 3) = UCase("apellido")
.TextMatrix(0, 4) = UCase("eliminar")

.RowHeight(0) = 300
.ColWidth(0) = 400
.ColWidth(1) = 1600
.ColWidth(2) = 1600
.ColWidth(3) = 2000
' -- Ancho de la imagen ( 60 pixeles + 2 para el margen )
.RowHeightMin = (IMAGE_HEIGHT * Screen.TwipsPerPixelX) + (Screen.TwipsPerPixelX * 2)

i = 1
 sql = "SELECT DISTINCT login,nombres,apellidos,cod_adm" & _
      " FROM  administrador"
 Call reg.Open(sql, conn)
  'SI EXISTE EL REGISTRO Y MUESTRA INGRESADOS DESDE EL COMBO
 If (reg.EOF = True) Then 'NO existe
   reg.Close
 Else
    While reg.EOF = False
   If i <= .Rows - 1 Then
    .TextMatrix(i, 1) = reg!login
    .TextMatrix(i, 2) = reg!nombres
    .TextMatrix(i, 3) = reg!apellidos
    .TextMatrix(i, 5) = reg!cod_adm
   
   If i <> 1 Then
    .col = 4: .Row = i
   ' -- Leer la imagen desde el disco y Establecerla en la celda
   Set .CellPicture = LoadPicture(App.Path & "\dibu\user_delete_48.gif") ' & rs(sImageField) & ".jpg")
   .TextMatrix(i, 4) = "" 'UCase("eliminar")
   End If
   
    i = i + 1
   End If
    reg.MoveNext
    Wend
    reg.Close
  End If

End With
'ocultar columna
listas.ColWidth(5) = 0
'listas.ColIsVisible (3)

Case Is = 2 'TIPO DE CAMBIO
lista.Caption = "TIPO DE CAMBIO"

cont = CInt(devolverCont("count(referencia)", " tipo_cambio", 0))
i = 1
With listas
.Rows = cont + 1
.Cols = 5

.TextMatrix(0, 0) = "Nro."
.TextMatrix(0, 1) = UCase("referencia")
.TextMatrix(0, 2) = UCase("fecha")
.TextMatrix(0, 3) = UCase("moneda ") & "$us."
.TextMatrix(0, 4) = UCase("eliminar")
.RowHeight(0) = 300
.ColWidth(0) = 400
.ColWidth(1) = 2700
.ColWidth(2) = 1200
.ColWidth(3) = 1450
sql = "SELECT DISTINCT referencia,fecha,tipo_us" & _
      " FROM  tipo_cambio"
 Call reg.Open(sql, conn)
  'SI EXISTE EL REGISTRO Y MUESTRA INGRESADOS DESDE EL COMBO
 If (reg.EOF = True) Then 'NO existe
   reg.Close
 Else
    While reg.EOF = False
   If i <= .Rows - 1 Then
    .TextMatrix(i, 1) = reg!referencia
    .TextMatrix(i, 2) = reg!fecha
    .TextMatrix(i, 3) = reg!tipo_us
    .col = 4: .Row = i
   ' -- Leer la imagen desde el disco y Establecerla en la celda
   Set .CellPicture = LoadPicture(App.Path & "\dibu\eliminar.jpg") ' & rs(sImageField) & ".jpg")
   .TextMatrix(i, 4) = "" 'UCase("eliminar")
   .CellPictureAlignment = 4 'CENTRAR LA IMAGEN
    i = i + 1
   End If
    reg.MoveNext
    Wend
    reg.Close
  End If
  .WordWrap = True
   
End With

End Select
With listas
For i = 1 To .Rows - 1
.TextMatrix(i, 0) = i & ".-"
'.ColWidth(i) = 1500 '2000
.ColAlignment(0) = 2
Next i
End With
'iniciar el scroll msflexgrid
 IniciarScroll listas
End Sub
Private Sub cmd_add_Click()
If band = 1 Then
With usuarios
bandModi = 1 'nuevo
.Show vbModal
End With
ElseIf band = 2 Then
With tipo_Cambio
.Show vbModal
End With
End If
End Sub
Private Sub cmd_edit_Click()
Dim aux As String, aux1 As Integer
Dim explode() As String

'If cadParametros = "" Then aux = listas.TextMatrix(listas.Row, 1)
aux = listas.TextMatrix(listas.Row, 1)
'aux1 = CInt(devolverCod(" nivel as cod", "administrador", "login='" & aux & "'", 0))

If band = 1 Then

If listas.Row <> 1 Then 'no edita el admin

bandModi = 2 'editar
With usuarios
'Select Case cadParametros
'Case Is = ""

.flex_analisis.TextMatrix(1, 1) = devolverCod(" cargo as cod", "administrador", "login='" & aux & "'", 0)
.flex_analisis.TextMatrix(2, 1) = devolverCod(" login as cod", "administrador", "login='" & aux & "'", 0)
.flex_analisis.TextMatrix(3, 1) = Trim$(devolverCod(" contrasena as cod", "administrador", "login='" & aux & "'", 0))
.flex_analisis.TextMatrix(4, 1) = devolverCod(" nombres as cod", "administrador", "login='" & aux & "'", 0)
.flex_analisis.TextMatrix(5, 1) = devolverCod(" apellidos as cod", "administrador", "login='" & aux & "'", 0)
.txt_pass.Text = listas.TextMatrix(listas.Row, 5)
.lbl_pass.Caption = .flex_analisis.TextMatrix(3, 1) 'copiar el password
.flex_analisis.TextMatrix(3, 1) = msflexpass(.lbl_pass) 'muestrro la cantidad elementos que tiene
aux1 = CInt(devolverCod(" nivel as cod", "administrador", "login='" & aux & "'", 0))
If aux1 = 1 Then
.cmb_nivel.ListIndex = 0

ElseIf aux1 = 2 Then
.cmb_nivel.ListIndex = 1
End If
'Case Is <> ""
'Call colocarpass(cadParametros)
'End Select
.Show vbModal
End With
'If cadParametros = "" Then
Unload Me
lista.Show
'End If
End If 'fin el admin

ElseIf band = 2 Then
aux = listas.TextMatrix(listas.Row, 2) 'fecha
If aux <> "" Then
explode = Split(aux, "/")
aux = explode(2) & "-" & explode(1) & "-" & explode(0)
End If

With tipo_Cambio
.cmd_guardar.Caption = "EDITAR"
.txt_referencia.Text = devolverCod(" referencia as cod", "tipo_cambio", "fecha='" & aux & "'", 0)
.txt_cambio.Text = devolverCod(" tipo_us as cod", "tipo_cambio", "fecha='" & aux & "'", 0)
.dtp_tipoCambio = explode(0) & "/" & explode(1) & "/" & explode(2)
aux = explode(2) & "/" & explode(1) & "/" & explode(0)
.lblId.Caption = devolverCod(" cod_tipoCambio as cod", "tipo_cambio", "referencia='" & listas.TextMatrix(listas.Row, 1) & "' and fecha='" & aux & "'", 0)

.Show vbModal

End With

End If

End Sub


Private Sub listas_Click()
Dim aux As String, aux1 As String

aux1 = listas.col
If listas.col <> 4 Then
Call cmd_edit_Click
Else
 If band = 1 Then
   If listas.Row <> 1 Then Call borrar
 Else
 Call borrar
 End If
End If
End Sub
Sub borrar()
Dim aux As String, aux1 As String
Dim sql As String, explode() As String

Select Case band

Case Is = 1
aux = listas.TextMatrix(listas.Row, 1)
sql = "DELETE FROM administrador1" & _
      " WHERE login='" & aux & "'"
aux1 = MsgBox("Esta seguro de borrar usuario", vbOKCancel, "Borrar")
'If aux1 = "" Or aux1 = 2 Then aux1 = 0
Case Is = 2

explode = Split(listas.TextMatrix(listas.Row, 2), "/"): aux = explode(2) & "/" & explode(1) & "/" & explode(0)
aux1 = devolverCod(" cod_tipoCambio as cod", "tipo_cambio", "referencia='" & listas.TextMatrix(listas.Row, 1) & "' and fecha='" & aux & "'", 0)

sql = "DELETE FROM tipo_cambio" & _
      " WHERE cod_tipoCambio=" & aux1 & " and fecha='" & aux & "'"
aux1 = MsgBox("Esta seguro de borrar tipo cambio", vbOKCancel, "Borrar")
'If aux1 = "" Or aux1 = 2 Then aux1 = 0
End Select
If aux1 = "" Or aux1 = 2 Then aux1 = 0

If CInt(aux1) = 1 Then
 Call finsert_Ado(sql, conn)
  Unload Me
 lista.Show
 End If

End Sub
